package com.innovations.inn.service.impl;

import java.util.List;

import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.OperateRecordMapper;
import com.innovations.inn.domain.OperateRecord;
import com.innovations.inn.service.IOperateRecordService;

/**
 * 科研成果操作记录Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class OperateRecordServiceImpl implements IOperateRecordService 
{
    @Autowired
    private OperateRecordMapper operateRecordMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询科研成果操作记录
     * 
     * @param operateRecordId 科研成果操作记录主键
     * @return 科研成果操作记录
     */
    @Override
    public OperateRecord selectOperateRecordByOperateRecordId(Long operateRecordId)
    {
        return operateRecordMapper.selectOperateRecordByOperateRecordId(operateRecordId);
    }

    /**
     * 查询科研成果操作记录列表
     * 
     * @param operateRecord 科研成果操作记录
     * @return 科研成果操作记录
     */
    @Override
    public List<OperateRecord> selectOperateRecordList(OperateRecord operateRecord)
    {
        return operateRecordMapper.selectOperateRecordList(operateRecord);
    }

    /**
     * 新增科研成果操作记录
     * 
     * @param operateRecord 科研成果操作记录
     * @return 结果
     */
    @Override
    public int insertOperateRecord(OperateRecord operateRecord)
    {
        return operateRecordMapper.insertOperateRecord(operateRecord);
    }

    /**
     * 修改科研成果操作记录
     * 
     * @param operateRecord 科研成果操作记录
     * @return 结果
     */
    @Override
    public int updateOperateRecord(OperateRecord operateRecord)
    {
        return operateRecordMapper.updateOperateRecord(operateRecord);
    }

    /**
     * 批量删除科研成果操作记录
     * 
     * @param operateRecordIds 需要删除的科研成果操作记录主键
     * @return 结果
     */
    @Override
    public int deleteOperateRecordByOperateRecordIds(Long[] operateRecordIds)
    {
        return operateRecordMapper.deleteOperateRecordByOperateRecordIds(operateRecordIds);
    }

    /**
     * 删除科研成果操作记录信息
     * 
     * @param operateRecordId 科研成果操作记录主键
     * @return 结果
     */
    @Override
    public int deleteOperateRecordByOperateRecordId(Long operateRecordId)
    {
        return operateRecordMapper.deleteOperateRecordByOperateRecordId(operateRecordId);
    }

    /**
     * 实体数据补全
     *
     * @param operateRecord 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(OperateRecord operateRecord, Long userId, Integer crateType) {
        //主键
        if (operateRecord.getOperateRecordId() == null || "".equals(operateRecord.getOperateRecordId())) {
            operateRecord.setOperateRecordId(idGeneratorSnowflake.nextId());
        }
//        //创建人、创建时间
//        if (crateType == 1) {
//            if (operateRecord.getCreateBy() == null || "".equals(operateRecord.getCreateBy())) {
//                operateRecord.setCreateBy(userId);
//            }
//            if (operateRecord.getCreateTime() == null) {
//                operateRecord.setCreateTime(DateUtils.getNowDate());
//            }
//        }
//        //修改人
//        if (operateRecord.getModifyBy() == null) {
//            operateRecord.setModifyBy(userId);
//        }
//        //修改时间
//        if (operateRecord.getModifyTime() == null) {
//            operateRecord.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
